import { RootState } from '@/store/rootReducer';
import {
  Action,
  createSlice,
  PayloadAction,
  ThunkAction,
} from '@reduxjs/toolkit';

import * as asyncAction from './login-action';

interface LoginState {
  login: boolean;
}

const initialState: LoginState = { login: false };

const counterSlice = createSlice({
  name: 'login',

  initialState,

  reducers: {
    setLogin(state, action: PayloadAction<{ status: boolean }>) {
      state.login = action.payload.status;
    },
  },
  extraReducers: {},
});

export type AppThunk = ThunkAction<void, RootState, unknown, Action<string>>;

export default { ...counterSlice.actions };

export const staticActions = counterSlice.actions;

export const LoginReducer = counterSlice.reducer;

export const actions = { ...asyncAction, ...counterSlice.actions };
